home *** CD-ROM | disk | FTP | other *** search
/ Ahoy 1987 July / Ahoy_Magazine_87-07_1987_Double_L_Side_A.d64 / Bmap Tutorial (.txt) < prev    next >
Commodore BASIC  |  2022-10-26  |  2KB  |  72 lines

  1. 1 rem bit map tutorial
  2. 2 rem    with color
  3. 3 rem       by
  4. 4 rem morton kevelson
  5. 10 poke 56578,peek(56578) or 3:rem set cia for output
  6. 15 a=0:rem video bank 3 ($c000-$ffff)
  7. 20 poke 56576,(peek(56576) and 252) or a:rem select video bank
  8. 30 poke 53265,peek(53265) or 32:rem set hi-res
  9. 40 os=peek(53272):rem store original screen location
  10. 50 poke 53272,peek(53272) or 8:rem set bit map offset to 8192
  11. 60 poke 53272,peek(53272) and 15:rem set screen offset to 0
  12. 70 bm=57344:rem start of bit map
  13. 80 sm=49152:rem start of screen
  14. 90 cm=55296:rem start of color mem
  15. 100 bg=53281:rem bground for multicolor
  16. 105 hn=0:ln=1:cn=6:bc=14:sc=hn*16+ln:rem start colors
  17. 110 for i=0 to 999:rem clear screen and set colors
  18. 120 poke sm+i,sc:rem set screen colors
  19. 130 poke cm+i,cn:rem set color mem
  20. 140 next i
  21. 150 poke bg,bc:rem set bground color
  22. 160 for i=0 to 7999:rem clear bit map
  23. 170 poke bm+i,0
  24. 180 next i
  25. 190 r1=11:rem start screen row
  26. 200 r2=14:rem end screen row
  27. 210 c1=18:c2=22:rem start & end column
  28. 220 nb=(c2-c1)*8+7:rem number of bytes per row
  29. 230 rem fill patterns
  30. 235 data 102,68,85,170,204,99
  31. 240 cn=6:ct=cn:rem number of fill patterns
  32. 250 read pt:ct=ct-1:if ct=0 then ct=cn:restore
  33. 260 gosub 1000
  34. 270 gosub 2000
  35. 280 goto 250
  36. 1000 for ro=r1 to r2:rem fill with pattern
  37. 1010 fi=bm+ro*320+c1*8:rem calc first row byte
  38. 1020 for j=0 to nb:rem fill row
  39. 1030 poke fi+j,pt
  40. 1040 next j
  41. 1050 next ro
  42. 1060 return
  43. 2000 get a$
  44. 2010 if a$="[133]" then poke 53270,peek(53270) and 239:rem f1=hi-res
  45. 2020 if a$="[134]" then poke 53270,peek(53270) or 16:rem f3=multi-color
  46. 2030 if a$="[135]" then return:rem f5=get next pattern
  47. 2040 if a$="[136]" goto 3000:rem f7=quit
  48. 2050 if a$="[137]" then mm=sm:gosub4000:gosub4100:rem hi-nybble
  49. 2060 if a$="[138]" then mm=sm:gosub4020:gosub4100:rem lo-nybble
  50. 2070 if a$="[139]" then mm=cm:gosub4040:gosub4100:rem color mem
  51. 2080 if a$="[140]" then gosub4060:rem bground nybble
  52. 2090 goto2000
  53. 3000 poke 56576,(peek(56576) and 252) or 3:rem restore text display
  54. 3010 poke 53265,(peek(53265) and 223)
  55. 3020 poke 53270,peek(53270) and 239
  56. 3030 poke 53272,os:poke bg,6:for i=0 to 999:poke cm+i,14:next i
  57. 3040 end
  58. 4000 hn=hn+1:if hn>15 then hn=0
  59. 4010 cv=hn*16+ln:return
  60. 4020 ln=ln+1:if ln>15 then ln=0
  61. 4030 goto 4010
  62. 4040 cn=cn+1:if cn>15 then cn=0:cv=0:return
  63. 4050 cv=cn:return
  64. 4060 bc=bc+1:if bc>15 then bc=0
  65. 4070 poke bg,bc:return
  66. 4100 for ro=r1 to r2
  67. 4110 fs=mm+ro*40+co
  68. 4120 for cb=c1 to c2
  69. 4130 poke fs+cb,cv
  70. 4140 next cb:next ro
  71. 4150 return
  72.